package com.minelx.scriptbuilder.script.attribute.function;

import com.minelx.scriptbuilder.script.IVariable;
import com.minelx.scriptbuilder.script.attribute.value.IAttribute;

public final class Method implements Function {

	private final Function decorated;

	private IAttribute self;

	public Method(Function decorated) {
		this.decorated = decorated;
	}

	@Override
	public final IAttribute execute(Params params) {
		params.setFirst(IVariable.immediate(self));
		return decorated.execute(params);
	}

	@Override
	public void belongsTo(IAttribute parent) {
		self = parent;
	}

	public void setContext(IAttribute self) {
		this.self = self;
	}
}
